//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<resource_center.h>
///	@path	~/src/engine/xcore/
///	@date	2007/11/29
///	@desc	Manages engine resources.

#pragma once

#include "xeres.h"

#include "lib/system/lock.h"
#include "lib/utilities/dict.h"

#include "database/IData.h"
#include "database/DataManager.h"

#include "graphics/IEffect.h"
#include "graphics/IGeometry.h"
#include "graphics/IModel.h"

#include "scene/resource/ResourceLoader.h"

#include "engine/xcore/task_manager.h"

namespace xeres {

	enum ResourceType
	{
		RES_NULL		= 0 ,	// indicate no resource, or invalid resource
		RES_PLACEHOLDER ,		// holds a name, or resource is processing
		RES_BINARY ,			// pure binary data
		RES_POINTS ,			// a points collection
		RES_CURVES ,			// a curves collection
		RES_MESHES ,			// a mesh geometry collection
		RES_MODEL ,				// a packed model, holds with effects & geometry
		RES_EFFECT ,			// a compiled effect
		RES_FXSRC ,				// fx source file
		RES_TEXTURE ,			// generic texture

		RES_last
	};

	/*!
		\class	ResourceCenter
		\brief	Manages nearly all engine resources.
				Resources are maintained as a list of data.
				Client core send requisites list to engine,
				engine dispatching data loading process,
				and resource center collect them to become a res-pack.
	*/
	class ResourceCenter : public ResourceLoader
	{
	protected:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		ResourceCenter( void );

		/// \dtor
		~ResourceCenter( void );

		//@}

		/// \name Internal Manipulation
		//@{

		/*!
			\brief		Initialize resource center.
		*/
		void Initialize( RenderManager * renderman );

		/*!
			\brief		Finalize resource center.
		*/
		void Finalize( void );

		//@}

	public:

	// resource management

		/*!
			\brief		Get resource type by name.
		*/
//		ResourceType QueryResource( const WString& name );

		/*!
			\brief		Get resource by name.
						Notice! If resource is not loaded, will return NULL instead of loading it.
						Use load resource to schedule a loading.
		*/
//		RefPass<IObject> GetResource( const WString& name );

		/*!
			\brief		Load resource by name.
						Try to match resource description, and return false while no resource matched.
		*/
//		bool LoadResource( const WString& name , const Callback< void , RefWeak<IObject> >& complete_call );

	// resource loading

		/*!
			\brief		Load geometry(s) description.
		*/
//		bool LoadMeshes( const WString& path , const Callback< void, RefWeak<IGeometry> >& complete_call );

	private:

	//@ data

	};

} // namespace xeres
